package mm.chenchen.modules.mh.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;

@Data
@TableName("mh_expand_attribute")
public class MhExpandAttribute implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableField(exist = false)
    private String operName;

    /**
     * =========================================================
     */

    @TableId
    private Long id;
    private Double blood = 0d;
    private Double magic = 0d;
    private Double armor = 0d;
    private Double resistance = 0d;
    private Double spellAttack = 0d;
    private Double attack = 0d;
    private Double hit = 0d;
    private Double speed = 0d;
    private Double evade = 0d;
    private Long type;


    public MhExpandAttribute() {
    }

    public MhExpandAttribute(Double blood, Double magic, Double armor, Double resistance, Double spellAttack, Double attack, Double speed, Double evade) {
        this.blood = blood;
        this.magic = magic;
        this.armor = armor;
        this.resistance = resistance;
        this.spellAttack = spellAttack;
        this.attack = attack;
        this.speed = speed;
        this.evade = evade;
    }

    public void add(MhExpandAttribute add) {
        this.blood = new BigDecimal(blood).add(new BigDecimal(add.getBlood())).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.magic = new BigDecimal(magic).add(new BigDecimal(add.getMagic())).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.armor = new BigDecimal(armor).add(new BigDecimal(add.getArmor())).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.resistance = new BigDecimal(resistance).add(new BigDecimal(add.getResistance())).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.spellAttack = new BigDecimal(spellAttack).add(new BigDecimal(add.getSpellAttack())).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.attack = new BigDecimal(attack).add(new BigDecimal(add.getAttack())).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.speed = new BigDecimal(speed).add(new BigDecimal(add.getSpeed())).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.evade = new BigDecimal(evade).add(new BigDecimal(add.getEvade())).setScale(0, RoundingMode.HALF_UP).doubleValue();
    }

    public void handleWithBaseCount(int counts) {
        this.blood = new BigDecimal(blood).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.magic = new BigDecimal(magic).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.armor = new BigDecimal(armor).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.resistance = new BigDecimal(resistance).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.spellAttack = new BigDecimal(spellAttack).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.attack = new BigDecimal(attack).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.speed = new BigDecimal(speed).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
        this.evade = new BigDecimal(evade).multiply(new BigDecimal(counts)).setScale(0, RoundingMode.HALF_UP).doubleValue();
    }

    public static MhExpandAttribute getBase() {
        MhExpandAttribute base = new MhExpandAttribute();
        base.setBlood(100d);
        base.setMagic(80d);
        base.setArmor(0d);
        base.setResistance(0d);
        base.setSpellAttack(0d);
        base.setAttack(30d);
        base.setHit(20d);
        base.setSpeed(0d);
        base.setEvade(10d);
        return base;
    }

    public static MhExpandAttribute handleByBaseAttr(int raceId, int attrId) {
        MhExpandAttribute expandAttribute = new MhExpandAttribute();

        switch (raceId) {
            case 1:
                switch (attrId) {
                    case 1:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 0d, 0.4d, 0.4d, 0.66d, 0.1d, 0d);
                        break;
                    case 2:
                        expandAttribute = new MhExpandAttribute(0d, 3d, 0d, 0.7d, 0.7d, 0d, 0d, 0d);
                        break;
                    case 3:
                        expandAttribute = new MhExpandAttribute(5d, 0d, 0d, 0.3d, 0.3d, 0d, 0.1d, 0d);
                        break;
                    case 4:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 1.5d, 0.2d, 0.2d, 0d, 0.1d, 0d);
                        break;
                    case 5:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 0d, 0d, 0d, 0d, 0.7d, 1d);
                        break;

                }
                break;
            case 2:
                switch (attrId) {
                    case 1:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 0d, 0.4d, 0.4d, 0.76d, 0.1d, 0d);
                        break;
                    case 2:
                        expandAttribute = new MhExpandAttribute(0d, 2.5d, 0d, 0.7d, 0.7d, 0d, 0d, 0d);
                        break;
                    case 3:
                        expandAttribute = new MhExpandAttribute(6d, 0d, 0d, 0.3d, 0.3d, 0d, 0.1d, 0d);
                        break;
                    case 4:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 1.4d, 0.2d, 0.2d, 0d, 0.1d, 0d);
                        break;
                    case 5:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 0d, 0d, 0d, 0d, 0.7d, 1d);
                        break;
                }
                break;
            case 3:
                switch (attrId) {
                    case 1:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 0d, 0.4d, 0.4d, 0.56d, 0.1d, 0d);
                        break;
                    case 2:
                        expandAttribute = new MhExpandAttribute(0d, 3.5d, 0d, 0.7d, 0.7d, 0d, 0d, 0d);
                        break;
                    case 3:
                        expandAttribute = new MhExpandAttribute(4.5d, 0d, 0d, 0.3d, 0.3d, 0d, 0.1d, 0d);
                        break;
                    case 4:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 1.6d, 0.2d, 0.2d, 0d, 0.1d, 0d);
                        break;
                    case 5:
                        expandAttribute = new MhExpandAttribute(0d, 0d, 0d, 0d, 0d, 0d, 0.7d, 1d);
                        break;
                }


        }
        return expandAttribute;
    }

}
